var Tiantianwailian = function(links_id,platfrom,url,path,username,isshow,urlscheme,end_time) {  
    var obj = new Object();
    var userAgent = navigator.userAgent;
    var nowtime = Math.round(new Date().getTime()/1000).toString();
    obj.init = function(){
        if (end_time > 1 && end_time < nowtime) {
            $("#public-web-container").html('<img class="error-images" src="https://nilife.oss-cn-beijing.aliyuncs.com/miniapp/images/setting/error.png"><p class="error-msg">会员已过期,请充值！</p>');
            return "会员已过期,请充值后重新生成！";
        }
        var mobile_flag = this.isMobile();
        var browser = this.browser();
        if(mobile_flag){
            if (browser == "MicroMessenger") {
                if (platfrom != 1) {
                    window.location.href="https://bab.moreqifu.cn/openminiapp/"+links_id+"?platfrom="+platfrom;
                } else {
                    window.location.href=url;
                }
            // } else if (browser == "baiduboxapp") {
            //     $(".notice-msg").html("如点击无法跳转微信,请点击底部分享到微信好友打开；或使用微信扫码。");
            //     $("#public-web-jump-button").html("点击立即前往微信");
            //     $(".qrcodes").show();
            } else if (browser == "UCBrowser") {
                $("#public-web-jump-button").html("点击立即前往微信");
                $("#dianjiimg").show();
            } else if (browser == "Weibo") {
                if (path == "") {
                    let noticemsg = "您的配置无法在微博跳转小程序,请使用小程序-密钥版创建外链！";
                } else {
                    let noticemsg = "正在跳转微信小程序,如未自动打开微信请点击下方按钮!";
                }
                $(".notice-msg").html(noticemsg);
                $("#public-web-jump-button").attr("href","sinaweibo://wbdiversion?username="+username+"&path="+path);
                window.location.href="sinaweibo://wbdiversion?username="+username+"&path="+path;
            } else {
                if (isshow == 2) {
                    $("#dianjiimg").show();
                }
                window.location.href=urlscheme;                    
                setTimeout(function (){
                    $("#public-web-jump-button").html("点击立即前往微信");
                    $("#dianjiimg").show();
                }, 3000);
            }
        } else {
            console.log(mobile_flag);
            if (platfrom != 1) {
                $(".notice-msg").html("请扫描下方二维码,使用手机访问本网页！");
                $(".qrcodes").show();
                $("#public-web-jump-button").css({"background-color":"#CCCCCC","color":"#333333"}).html("扫码下方二维码");
            } else {
                window.location.href=url;
            }
        }
    }

    obj.vendor = function(){
        if (userAgent.search("Windows NT") != -1) {
            pvendor = "Windows";
        } else if (userAgent.search("iPhone") != -1) {
            pvendor = "iPhone";
        } else if (userAgent.search("iPad") != -1) {
            pvendor = "iPad";
        } else if (userAgent.search("Android") != -1) {
            pvendor = "Android";
        } else if (userAgent.search("Macintosh") != -1) {
            pvendor = "Mac";
        } else {
            pvendor = "Other";
        }
        return pvendor;
    }
    obj.browser = function() {
        // 判断访问是什么设备
        if (userAgent.search('MicroMessenger') != -1) {
            // 微信浏览器
            browser = "MicroMessenger";
        } else if(userAgent.search('QQBrowser') != -1){
            // 电脑QQ浏览器
            browser = "QQBrowser";
        } else if(userAgent.search('VivoBrowser') != -1){
            // Vivo浏览器
            browser = "VivoBrowser";
        } else if(userAgent.search('HeyTapBrowser') != -1){
            // Oppo浏览器
            browser = "HeyTapBrowser";
        } else if(userAgent.search('HuaweiBrowser') != -1){
            // 华为浏览器
            browser = "HuaweiBrowser";
        } else if(userAgent.search('MiuiBrowser') != -1){
            // 小米浏览器
            browser = "MiuiBrowser";
        } else if(userAgent.search('MQQBrowser') != -1){
            // QQ浏览器
            browser = "MQQBrowser";
        } else if(userAgent.search('AlipayClient') != -1){
            // 支付宝浏览器
            browser = "AlipayClient";
        } else if(userAgent.search('baiduboxapp') != -1){
            // 百度APP
            browser = "baiduboxapp";
        } else if(userAgent.search('Weibo') != -1){
            // 微博浏览器
            browser = "Weibo";
        } else if(userAgent.search('iqiyi') != -1){
            // 爱奇艺浏览器
            browser = "iqiyi";
        } else if(userAgent.search('aweme') != -1){
            // 小米浏览器
            browser = "aweme";
        } else if(userAgent.search('kdtUnion_iting') != -1){
            // 喜马拉雅
            browser = "kdtUnion_iting";
        } else if(userAgent.search('DingTalk') != -1){
            // 钉钉
            browser = "DingTalk";
        } else if(userAgent.search('UCBrowser') != -1 || userAgent.search('Quark') != -1){
            // UC浏览器
            browser = "UCBrowser";
        } else if(userAgent.search('SamsungBrowser') != -1){
            // 三星浏览器
            browser = "SamsungBrowser";
        } else if(userAgent.search('NokiaBrowser') != -1){
            // 诺基亚浏览器
            browser = "NokiaBrowser";
        } else if(userAgent.search('Opera') != -1){
            // 欧朋
            browser = "Opera";
        } else if(userAgent.search('Firefox') != -1){
            // 火狐
            browser = "Firefox";
        } else if(userAgent.search('Zhihu') != -1 || userAgent.search('hihu') != -1){
            // 知乎
            browser = "Zhihu";
        } else if(userAgent.search('LarkLocale') != -1){
            browser = "Feishu";
        } else if(userAgent.search('iPhone') != -1){
            browser = "iPhone";
        } else if(userAgent.search('iPad') != -1){
            browser = "iPad";
        } else if(userAgent.search('Macintosh') != -1){
            browser = "Mac";
        } else {
            browser = "Other";
        }
        return browser;
    }
    obj.isMobile = function() {
        if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|XiaoMi|IEMobile)/i)) {
            return true;
        } else {
            return false;
        }
    }
    return obj;  
}